package 线程状态;

/**
 * @Author: 李佳芬
 * @Description: 线程礼让
 * @DateTime: 2023/3/31 17:06
 **/
public class TestYield implements Runnable{
    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName()+"我线程开始执行了，愿你此生常如意，万里山河无敌人");
        Thread.yield();
        System.out.println(Thread.currentThread().getName()+"我要走了，再见");
    }

    public static void main(String[] args) {
        TestYield testYield = new TestYield();
        TestYield testYield1 = new TestYield();

        new Thread(testYield,"你你你").start();
        new Thread(testYield1,"哈哈哈").start();
    }
}
